import { IsEnum, IsNotEmpty, IsOptional, IsString, IsUUID, Length, Matches } from 'class-validator';

export class CreateDiscussionPostDto {
  @IsString()
  @IsNotEmpty({ message: '标题不能为空' })
  @Length(5, 50, { message: '标题长度应在5到50个字符之间' })
  title: string;

  @IsString()
  @IsOptional()
  @Length(0, 2000, { message: '内容长度不能超过2000个字符' })
  content?: string;

  @IsEnum(['apartment', 'roommate', 'experience', 'question', 'other'], {
    message: '分类必须是以下之一: apartment, roommate, experience, question, other'
  })
  @IsOptional()
  category?: string;

  @IsNotEmpty({ message: '作者ID不能为空' })
  @Matches(/^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i, {
    message: '作者ID必须是有效的UUID格式'
  })
  authorId: string;
} 